package com.yitongmao.activity;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.google.gson.Gson;
import com.yitongmao.bean.OrderSuccessBean;
import com.yitongmao.core.cache.ACache;
import com.yitongmao.yitmfruit.R;

import butterknife.Bind;
import butterknife.ButterKnife;

public class IndentSuccessActivity extends AppCompatActivity {
    @Bind(R.id.tv_title)
    TextView tvTitle;
    @Bind(R.id.successPrice)
    TextView successPrice;
    @Bind(R.id.successWay)
    TextView successWay;
    @Bind(R.id.mUserZH)
    TextView mUserZH;
    @Bind(R.id.mKaiHuHang)
    TextView mKaiHuHang;
    @Bind(R.id.mLianHangHao)
    TextView mLianHangHao;
    @Bind(R.id.mHuiBianMa)
    TextView mHuiBianMa;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        immerSion();
        setContentView(R.layout.activity_indent_success);
        ButterKnife.bind(this);
        setData();
    }

    private void setData() {
        tvTitle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                IndentSuccessActivity.this.finish();
            }
        });
        String submitsuccess = ACache.get(IndentSuccessActivity.this).getAsString("submitsuccess");
        Gson gson=new Gson();
        OrderSuccessBean orderSuccessBean = gson.fromJson(submitsuccess, OrderSuccessBean.class);
        if (orderSuccessBean!=null){
            successPrice.setText(orderSuccessBean.pi.remark);
            successWay.setText(String.valueOf(orderSuccessBean.pi.payModeName));
            mUserZH.setText(String.valueOf(orderSuccessBean.pi.identifyNumber));
            mKaiHuHang.setText(String.valueOf(orderSuccessBean.pi.backState));
            mHuiBianMa.setText(orderSuccessBean.pi.remittanceCode);
        }
    }
    //沉浸式状态栏
    public void immerSion() {
        getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                    | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
            window.setNavigationBarColor(Color.BLACK);
        }
    }
}
